package cn.itcast.account.service;

import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.rm.tcc.api.BusinessActionContextParameter;
import io.seata.rm.tcc.api.LocalTCC;
import io.seata.rm.tcc.api.TwoPhaseBusinessAction;

/**
 * @Author: ahcfl
 * @Date: 2021年07月27日 19:35
 * @Description:
 */
@LocalTCC
public interface TCCAccountService {

    /*try方法  从账号中扣钱*/
    @TwoPhaseBusinessAction(name = "tryDeduct", commitMethod = "confirm", rollbackMethod = "cancel")
    void tryDeduct(@BusinessActionContextParameter(paramName = "userId") String userId,
                   @BusinessActionContextParameter(paramName = "money") int money);

    boolean confirm(BusinessActionContext ctx);

    /*BusinessActionContext 事务的上下文，包含事务信息，参数信息*/
    boolean cancel(BusinessActionContext ctx);
}
